package com.tsd.jxc.stock.entity;

import com.alibaba.fastjson.JSON;
import com.tsd.core.constants.Constants;
import com.tsd.core.utils.HlpUtils;
import com.tsd.core.utils.ListUtil;
import com.tsd.jxc.stock.StockConstants;
import io.swagger.annotations.ApiModel;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 调拨单扩展
 *
 * @author Hillpool
 * @date 2022/12/12 11:32:10
 */
@ApiModel(description = "调拨单扩展")
public class JxcStockTransferExt extends JxcStockTransfer implements Serializable {

    private String from_warehouse_name;
    private String to_warehouse_name;
    private BigDecimal price;
    private BigDecimal qty;
    private BigDecimal amount;
    private String package_unit;
    private String goods_name;
    private String specifications;
    private List<JxcStockTransferItemExt> item_list;
    private List<String> sid_list;

    public String getFrom_warehouse_name() {
        return from_warehouse_name;
    }

    public void setFrom_warehouse_name(String from_warehouse_name) {
        this.from_warehouse_name = from_warehouse_name;
    }

    public String getTo_warehouse_name() {
        return to_warehouse_name;
    }

    public void setTo_warehouse_name(String to_warehouse_name) {
        this.to_warehouse_name = to_warehouse_name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getQty() {
        return qty;
    }

    public void setQty(BigDecimal qty) {
        this.qty = qty;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getPackage_unit() {
        return package_unit;
    }

    public void setPackage_unit(String package_unit) {
        this.package_unit = package_unit;
    }

    public String getGoods_name() {
        return goods_name;
    }

    public void setGoods_name(String goods_name) {
        this.goods_name = goods_name;
    }

    public String getSpecifications() {
        return specifications;
    }

    public void setSpecifications(String specifications) {
        this.specifications = specifications;
    }

    public List<JxcStockTransferItemExt> getItem_list() {
        return item_list;
    }

    public void setItem_list(List<JxcStockTransferItemExt> item_list) {
        this.item_list = item_list;
    }

    public List<String> getSid_list() {
        return sid_list;
    }

    public void setSid_list(List<String> sid_list) {
        this.sid_list = sid_list;
    }

    public JxcStockInbillExt genInBill(String warehouse_sid) {
        JxcStockInbillExt inbillExt = new JxcStockInbillExt();
        inbillExt.setWarehouse_sid(warehouse_sid);
        inbillExt.setSrc_sid(this.getSid());
        inbillExt.setSrc_code(this.getCode());
        inbillExt.setIn_type(StockConstants.IN_TYPE_ALLOCATION);
        inbillExt.setIn_date(new Date());
        inbillExt.setAudit_state(Constants.DR_VALID);
        inbillExt.setExecute_state(Constants.DR_VALID);
        List<JxcStockTransferItemExt> detailExtList = this.getItem_list();
        List<JxcStockInbillItemExt> itemExtList = ListUtil.map(detailExtList, t -> t.genInBillItem());
        inbillExt.setItem_list(itemExtList);
        return inbillExt;
    }

    public JxcStockOutbillExt genOutBill(String warehouse_sid) {
        JxcStockOutbillExt outBillExt = new JxcStockOutbillExt();
        outBillExt.setWarehouse_sid(warehouse_sid);
        outBillExt.setOut_type(StockConstants.OUT_TYPE_ALLOCATION);
        outBillExt.setOut_date(new Date());
        outBillExt.setSrc_sid(this.getSid());
        outBillExt.setSrc_code(this.getCode());
        outBillExt.setExecute_state(Constants.DR_VALID);
        outBillExt.setAudit_state(Constants.DR_VALID);
        List<JxcStockTransferItemExt> detailExtList = this.getItem_list();
        List<JxcStockOutbillItemExt> itemExtList = ListUtil.map(detailExtList, t -> t.genOutBillItem());
        outBillExt.setItem_list(itemExtList);
        return outBillExt;
    }

    public String getGen_in_out_bill_name() {
        if (!HlpUtils.isEmpty(this.getGen_in_out_bill()) && this.getGen_in_out_bill().equals(StockConstants.DETAIL_IN_OUT_BILL_ALL)) {
            return "是";
        }
        return "否";
    }

    public String getAudit_state_name() {
        if (!HlpUtils.isEmpty(this.getAudit_state()) && this.getAudit_state().equals(StockConstants.STATE_AUDITED)) {
            return "已审核";
        }
        return "未审核";
    }

    public String getSpec_name() {
        return null;
    }

}
